using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DialectSoftware.Web.JsAPI;
using DialectSoftware.Web.UI.CustomUserControls;
using Demo.UserControls;

namespace Demo
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Filter("0.0");
                this.SliderControl1.Min = 0;
                this.SliderControl1.Max = 400;
              
            }

            this.LightBox1.DataSource = new object[] { 1 };
            this.LightBox1.DataBind();
            this.GridControl1.OnFilterGrid += new EventHandler<GridEventArgs>(GridControl1_OnFilterGrid);
            this.SliderControl1.OnSliderChange += new UserControls.SliderControl.SliderChangeHandler(SliderControl1_OnSliderChange);
        }

        void GridControl1_OnFilterGrid(object sender, GridEventArgs e)
        {
            Filter(e.Amount);
        }

        void SliderControl1_OnSliderChange(object sender, UserControls.SliderControlEventArgs args)
        {
            if (SliderControl1.Mode == ControlMode.Server && GridControl1.Mode == ControlMode.Server)
            {
                Filter(args.Value);
            }
        }

        private void Filter(string value)
        {
            float f;
            float.TryParse(value, out f);

            DataTable dt = new DataTable();
            dt.TableName = "Earnings";
            dt.Columns.Add("Company");
            dt.Columns.Add("Q1");
            dt.Columns.Add("Q2");
            dt.Columns.Add("Q3");
            dt.Columns.Add("Q4");

            if (f <= 50.3f)
            {
                dt.Rows.Add("Big Co. 1", 20.3f, 30.5f, 23.5f, 50.3f);
            }
            if (f <= 150.3f)
            {
                dt.Rows.Add("Big Co. 2", 100.3f, 90.5f, 80.5f, 150.3f);
            }
            if (f <= 400.3f)
            {
                dt.Rows.Add("Big Co. 3", 200.3f, 300.5f, 230.5f, 400.3f);
            }
            if (f <= 250.3f)
            {
                dt.Rows.Add("Big Co. 4", 80.3f, 99.5f, 199.5f, 250.3f);
            }

            DataSet ds = new DataSet();
            ds.Tables.Clear();
            ds.Tables.Add(dt);
            this.GridControl1.DataSource = ds;
            this.GridControl1.DataBind();
        }
    }
}

